import type { PageList, ResponseStruct } from '#/global'
import { UserVo } from '@/modules/base/api/user';

export interface ClassroomVo {
  id?: number;
  name?: string;
  school_id?: number;
  teacher_id?: number;
  department_id?: number;
  member_count?: number;
  created_at?: string;
  updated_at?: string;
  creator_id?: number;
  creator?: UserVo
}

export interface ClassroomSearchVo {
  name?: string,
  school_id?: number
}

export function page(data: ClassroomSearchVo): Promise<ResponseStruct<PageList<ClassroomVo>>> {
  return useHttp().get('/admin/classroom', { params: data })
}

export function create(data: ClassroomVo): Promise<ResponseStruct<null>> {
  return useHttp().post('/admin/classroom', data)
}

export function save(id: number, data: ClassroomVo): Promise<ResponseStruct<null>> {
  return useHttp().put(`/admin/classroom/${id}`, data)
}

export function deleteByIds(ids: number[]): Promise<ResponseStruct<null>> {
  return useHttp().delete('/admin/classroom', { data: ids })
}

export function assignTeacher(id: number, teacher_ids: string[]): Promise<ResponseStruct<null>> {
  return useHttp().put(`/admin/classroom/${id}/teachers`, { teacher_ids })
}
